/* eslint-disable no-unused-vars */
const express = require('express');
const { success, serverError } = require('../utils/resSender');

const router = express.Router();

router.post('/example', (req, res) => {

});

router.post('/run', (req, res) => {
    // 1. 使用更清晰的变量命名
    const baseCommand = ['run'];
    const additionalCommands = postBody2Command(req);

    // 2. 使用展开运算符合并数组
    const fullCommand = [...baseCommand, ...additionalCommands];

    // 3. 调用指令
    executeCommand(fullCommand, publicCallbacks(res))
});

router.post('/list', (req, res) => {
    // 1. 使用更清晰的变量命名
    const baseCommand = ['list'];
    const additionalCommands = postBody2Command(req);

    // 2. 使用展开运算符合并数组
    const fullCommand = [...baseCommand, ...additionalCommands];

    // 3. 调用指令
    executeCommand(fullCommand, publicCallbacks(res))
});

router.post('/install', (req, res) => {
    // 1. 使用更清晰的变量命名
    const baseCommand = ['install'];
    const additionalCommands = postBody2Command(req);

    // 2. 使用展开运算符合并数组
    const fullCommand = [...baseCommand, ...additionalCommands];

    // 3. 调用指令
    executeCommand(fullCommand, publicCallbacks(res))
});

router.post('/uninstall', (req, res) => {
    // 1. 使用更清晰的变量命名
    const baseCommand = ['uninstall'];
    const additionalCommands = postBody2Command(req);

    // 2. 使用展开运算符合并数组
    const fullCommand = [...baseCommand, ...additionalCommands];

    // 3. 调用指令
    executeCommand(fullCommand, publicCallbacks(res))
});

module.exports = router;